package 深入反射机制.反射构造方法Constructor.反编译构造方法.test01;

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.util.ResourceBundle;

public class ReflectTest01 {
    public static void main(String[] args) {
        StringBuffer s = new StringBuffer();

        ResourceBundle bundle = ResourceBundle.getBundle("invincibleConfiguration");
        try {
            Class aClass = Class.forName(bundle.getString("completeClassName"));
            s.append(Modifier.toString(aClass.getModifiers()));
            s.append(" class ");
            s.append(aClass.getSimpleName());
            s.append(" {\n");

            Constructor[] constructors = aClass.getDeclaredConstructors();
            for (Constructor constructor : constructors){
                s.append("\t");
                s.append(Modifier.toString(constructor.getModifiers()));
                s.append(" ");
                s.append(aClass.getSimpleName());
                s.append(" (");

                Class[] parameterTypes = constructor.getParameterTypes();
                for (Class parameterType : parameterTypes){
                    s.append(parameterType.getSimpleName());
                    s.append(",");
                }
                if (parameterTypes.length > 0){
                    s.deleteCharAt(s.length()-1);
                }


                s.append("){}\n");
            }
            s.append("}");
            System.out.println(s);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
